import {
	defineStore
} from 'pinia';
import {Http} from '@/core';
const store = {
	id: "dict",
	state() {
		return {

		}
	},

	getters: {
		/**
		 * 性别测试
		 * @returns {function(): *[]}
		 * @constructor
		 */
		DICT() {
			return async (typeName) => {
				let {
					data
				} = await Http.get("/common/dict", {
					typeName: typeName
				});

				let dataList = []
				if (!Helper.emptyArray(data)) {
					dataList = data
				}
				return dataList;
			}
		},

		STORE() {
			return async () => {
				let {code, data} = await Http.get("/store/getMyStore")
				return data.filter(x => x.status == 1).map(x => {
					return {label: x.storeName, value: x.storeId}
				});
			}
		}
	},

	actions: {
	        async get(options, query, cache) {
	            let {code, data} = await Http.get("/common/dict", {typeName: options});
	            return data;
	        }
	    }
}

export default defineStore(store)
